import { operateMgr } from './behavior/operateMgr.js';
import { operateLogin } from './behavior/operateLogin.js';
import { operateSteps } from './behavior/operateSteps.js';


window.mgrLib = {
    async init(_server) {
        this.ble_server = _server;
        await operateMgr.link(this.ble_server);
    },

    async login(password) {
        console.log("开始校验:", password, this.ble_server);
        // const _login = new login(this.ble_server);
        // await _login.link();
        // _login.checkPWD(password,false,(result)=>{
        //     log(result.matchStatus(result.mStatus));
        // });

        operateLogin.checkPWD(password, false, (result) => {
            log(result.matchStatus(result.mStatus));
        });
    },

    async step() {
        console.log("读取步数:");
        // const _walk = new walk(this.ble_server);
        // await _walk.link();
        // _walk.readStep((result) => {
        //     log("steps:" + result);
        // });
        operateSteps.readStep((result) => {
            log("steps:" + result.step);
        });
    }
};


// 动态加载另一个脚本
function loadExternalScript(url) {
    var script = document.createElement('script');
    script.src = url;
    document.head.appendChild(script);
}

// 引入另一个脚本
// loadExternalScript('login.js');